package com.supreme.stockserver.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.supreme.commonmybatis.mapper.StorageMapper;
import com.supreme.commonmybatis.entity.primary.MBStorage;
import com.supreme.commonboot.utils.AjaxResp;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping(value = "storage")
public class StorageController {

    @Resource
    private StorageMapper storageMapper;

    @GetMapping(value = "search")
    public AjaxResp searchStorage() {
        QueryWrapper<MBStorage> queryWrapper = new QueryWrapper<>();
        List<MBStorage> storageList = this.storageMapper.selectList(queryWrapper);
        return new AjaxResp(storageList);
    }

    @PostMapping(value = "create")
    public AjaxResp createStorage(@RequestBody MBStorage storage) {
        int insert = this.storageMapper.insert(storage);
        return new AjaxResp(insert);
    }

    @GetMapping(value = "selectRecord")
    public AjaxResp selectRecord(@RequestBody MBStorage storage) {
        int insert = this.storageMapper.insert(storage);
        return new AjaxResp(insert);
    }
}
